package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.purchase.RCPay;
import com.shrct.businessprocess.purchase.RCPayCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class RCPayCriteriaImpl extends HQLBasedPagedQueryCriteria<RCPay> implements RCPayCriteria {
  private RCProject project;
  
  public RCProject getProject() {
    return this.project;
  }
  
  public RCPayCriteria setProject(final RCProject project) {
    this.project = project;
    return this;			
    
  }
  
  private Date startDateFrom;
  
  public Date getStartDateFrom() {
    return this.startDateFrom;
  }
  
  public RCPayCriteria setStartDateFrom(final Date startDateFrom) {
    this.startDateFrom = startDateFrom;
    return this;			
    
  }
  
  private Date startDateTo;
  
  public Date getStartDateTo() {
    return this.startDateTo;
  }
  
  public RCPayCriteria setStartDateTo(final Date startDateTo) {
    this.startDateTo = startDateTo;
    return this;			
    
  }
  
  private Boolean isFinished;
  
  public Boolean getIsFinished() {
    return this.isFinished;
  }
  
  public RCPayCriteria setIsFinished(final Boolean isFinished) {
    this.isFinished = isFinished;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.purchase.impl.RCPayImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProject()) ){
    	hql += " and ((this.payRequest.thebudget.cbd.project) = (:project))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateFrom()) ){
    	hql += " and ((this.payRequest.theStartDate) >= (:startDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateTo()) ){
    	hql += " and ((this.payRequest.theStartDate) <= (:startDateTo))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getIsFinished()) ){
    	hql += " and ((this.payRequest.isFinished) = (:isFinished))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProject())){
    	query.setParameter("project",getProject()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateFrom())){
    	query.setParameter("startDateFrom",getStartDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateTo())){
    	query.setParameter("startDateTo",getStartDateTo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getIsFinished())){
    	query.setParameter("isFinished",getIsFinished()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCPayCriteriaImpl() {
    initOrderBys();
  }
}
